#include <QtCore/QCoreApplication>
#include "aesalgorithm.h"
#include <QDebug>

enum { RealTextLength  = 500 };

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

	int i = 0;
	int j = 0;
	unsigned char src[RealTextLength];
	unsigned char des[TextBlockLength];
	unsigned char check[RealTextLength];
	unsigned char key[AesKeyLength];
	int loop = 0;
	int tempLength = RealTextLength;
	int textLength = 0;

	while(loop++ != 10)
	{
		printf("loop = %d\n",loop);

		tempLength = RealTextLength;
		textLength = 0;

		memset(src,'8',RealTextLength);
		memset(des,0,TextBlockLength);
		memset(check,0,RealTextLength);
		memset(key,0,AesKeyLength);

		memset(key,'2',AesKeyLength);

		while (tempLength >0)
		{
			textLength = (tempLength <= TextBlockLength)? tempLength:TextBlockLength;

			aesEncrypt(src + (RealTextLength - tempLength),textLength,des,key);
			qDebug()<<"des:"<<(char *)des;
			aesDecrypt(des,check+(RealTextLength - tempLength),textLength,key);

			tempLength = tempLength - textLength;
		}


		for (j = 0; j != RealTextLength; j++)
			printf("%c",check[j]);
		printf("\n\n");
	}

    return a.exec();
}
